home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
pctjjl86.arc
/
ANIMATE.ARC
/
STANDXOR.ASM
< prev
next >
Wrap
Assembly Source File
|
1986-04-16
|
2KB
|
75 lines
; *** Listing 1 ***
;
;Standard XOR graphics driver for putting rectangular images into
; the Color/Graphics Adapter's medium-resolution memory map.
;
; Note: all registers preserved.
;
one segment para public 'CODE'
assume cs:one,ds:one,es:nothing
public form_driver
;
display_width db 80
line_counter db ?
;
form_driver proc near
push ax ;preserve all general registers
push bx
push cx
push dx
push si
push di
;
shr bl,1 ;are we starting in top or bottom 8K bank?
; also divides row by 2 to compensate for
; odd/even bank arrangement
jc starts_in_second_8k_bank
sub di,di ;even lines start in first 8K bank
jmp short calculate_row_offset
starts_in_second_8k_bank:
mov di,2000h ;odd lines start in second 8K bank
calculate_row_offset:
mov al,[display_width]
mul bl ;find the offset of top line of image
add di,ax ; relative to start of 8K bank
add di,cx ;ES:DI now points to byte at which to put
; the image's upper left corner
mov al,[si] ;get the height of the image
inc si ;point to form width
mov [line_counter],al ;store count of lines to draw
mov dl,[si] ;get the width of the image in bytes
sub dh,dh ;make 16 bit value
inc si ;point to start of form bytes
;
next_line:
mov cx,dx ;set the number of bytes/line for form
push di ;preserve offset of start of line
next_column:
mov al,[si] ;get this image byte
inc si ;point to the following image byte
xor es:[di],al ;exclusive-OR it into screen memory
inc di ;point to next screen memory position
loop next_column ;loop for next byte on line
pop di ;get back offset of start of this line
cmp di,2000h ;which 8K bank is next line in?
jb next_line_in_second_8k
sub di,2000h-50h ;point start of next line in 1st 8K
jmp short count_down_lines
next_line_in_second_8k:
add di,2000h ;point start of next line in 2nd 8K
count_down_lines:
dec [line_counter] ;count down number of lines
jne next_line ;jmp if any lines left
;if not, restore registers and
pop di ; return to calling program
pop si
pop dx
pop cx
pop bx
pop ax
ret
;
form_driver endp
one ends
end